/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: happyiu
 * Date: 2021-11-12
 * Time: 11:30
 */


/*
class animal{
    String name;
    int age;
    double height;

    public void eat(){
        System.out.println(name+"正在吃饭！");
    }

}


public class TestDemo {
    public static void main(String[] args) {
        animal animal1 =new animal();
        animal1.name = "wang";
        System.out.println(animal1.name);
    }


}
*/

/*
class Person {
    public int age;//成员属性 实例变量
    public String name;
    public String sex;
    public void eat() {//成员方法
        System.out.println("吃饭!");
    }
    public void sleep() {
        System.out.println("睡觉!");
    }
}

public class TestDemo {
    public static void main(String[] args) {
        Person person1 = new Person();//通过new实例化对象
        person1.eat();//普通成员方法调用需要通过对象的引用调用
        person1.sleep();
        //产生对象         实例化对象

        Person person2 = new Person();
        person2.name="hell";//初始化属性的值
        System.out.println(person2.name);//打印hell
        System.out.println(person2.age);//没初始化默认为0

        Person person3 = new Person();//创建多个成员

        //输出结果: 吃饭！ 睡觉！
    }
}
*/

/*class Person {
    //普通成员变量
    public String name;   // 字段
    public int age;

    //静态成员变量
    public static int count;

    //方法
    public void eat(){
        System.out.println("吃饭");
    }

    //类方法
    public static void use(){
        System.out.println("使用！！");
    }

}

public class TestDemo {
    public static void main(String[] args) {
        Person person1 = new Person();
        person1.age++;
        person1.count++;
        System.out.println(person1.age);
        System.out.println(person1.count);

        System.out.println("=================");
        Person person2 =new Person();
        person2.count++;
        System.out.println(person2.age);
        System.out.println(person2.count);

        // 执行结果
        //1
        //1
        //=================
        //0
        //2
    }
}*/

/*class Person {
    public String name;
    public int age;
}
class Test {
    public static void main(String[] args) {
        Person person = new Person();
        System.out.println(person.name.length());   // 获取字符串长度
    }
}
    // 执行结果
   *//* Exception in thread "main" java.lang.NullPointerException
        at Test.main(Test.java:9)*/


/*
class Person {
    public String name = "张三";
    public int age = 18;
}

public class TestDemo {
    public static void main(String[] args) {
        Person person = new Person();
        System.out.println(person.name);
        System.out.println(person.age);
    }
}
*/

/*class Person {
    public int age = 18;
    public String name = "张三";

    public void show() {
        System.out.println("我叫" + name + ", 今年" + age + "岁");
    }
}

public  class TestDemo {
    public static void main(String[] args) {
        Person person = new Person();
        person.show();
        Person person2 = new Person();
        person2.name = "李四";
        person2.age = 20;
        person2.show();

    }
}*/

class Test{

    public int a;

    public static int count;
    //静态成员变量 —— 类变量
}
public class TestDemo{

    public static void main(String[] args) {
        Test t1 = new Test();
        t1.a++;
        Test.count++;
        System.out.println(t1.a);
        System.out.println(Test.count);
        System.out.println("============");
        Test t2 = new Test();
        t2.a++;
        Test.count++;
        System.out.println(t2.a);
        System.out.println(Test.count);
    }
}


